package com.wswy.wzcx.statistics;

import com.tencent.bugly.crashreport.CrashReport;

public class BizReport {

  /**
   * 验证码发送失败
   */
  public static final int SEND_SMS_ERROR = 101;

  /**
   * 支付失败
   */
  public static final int PAY_ERROR = 111;

  /**
   * 穿山甲广告加载失败
   */
  public static final int TTAD_LOAD_ERROR = 121;

  /**
   * oss 上传失败
   */
  public static final int OSS_UPLOAD_ERROR = 131;


  public static final int GW122_PARSE_ERROR = 141;
  public static final int GW122_TIMEOUT =142;
  public static final int GW122_ERROR = 143;

  public static final int SY_ONEKEY_OPEN_ERROR = 145;
  public static final int SY_ONEKEY_LOGIN_ERROR = 146;
  public static final int SY_ONEKEY_PRE_ERROR = 147;

  public static void sendException(int exceptionType,String msg){

    String type = null;

    switch (exceptionType){
      case SEND_SMS_ERROR:
        type = "send_sms:";
        break;
      case PAY_ERROR:
        type = "order_pay:";
        break;
      case TTAD_LOAD_ERROR:
        type = "ttad_splash:";
        break;
      case OSS_UPLOAD_ERROR:
        type = "oss_upload:";
        break;
      case GW122_PARSE_ERROR:
        type = "gw122_parse:";
        break;
      case GW122_TIMEOUT:
        type = "gw122_getcookie:";
        break;
      case GW122_ERROR:
        type = "gw122_error:";
        break;
      case SY_ONEKEY_OPEN_ERROR:
        type = "sy_open";
        break;
      case SY_ONEKEY_LOGIN_ERROR:
        type = "sy_login";
        break;
      case SY_ONEKEY_PRE_ERROR:
        type = "sy_pre";
        break;
    }
    sendException(type+msg);

  }

  public static void sendException(String msg){
    if (msg != null) {
      CrashReport.postCatchedException(new BizReportException(msg));
    }
  }

  public static void postCatchedException(Throwable throwable){
    if (throwable != null){
      CrashReport.postCatchedException(throwable);
    }
  }


  private static class BizReportException extends RuntimeException {

    BizReportException(String message) {
      super(message);
    }

  }

}
